package cn.tedu.cs.baking.common.ex;

import cn.tedu.cs.baking.response.AppCode;
import lombok.Data;
@Data
public class BusinessException extends Exception {
    private int code;
    private String msg;

    public BusinessException(AppCode appCode,String message) {
        //message用于用户设置抛出错误详情
        super(message);
        this.code = appCode.getCode();
        this.msg = appCode.getMsg();
    }

    public BusinessException(AppCode appCode) {
        this.code = appCode.getCode();
        this.msg = appCode.getMsg();
    }

    //默认异常使用APP_ERROR状态码
    public BusinessException(String message) {
        super(message);
        this.code = AppCode.APP_ERROR.getCode();
        this.msg = AppCode.APP_ERROR.getMsg();
    }
}
